﻿
namespace ProgrammerToolsKits.ViewHelper
{
    using Windows.ApplicationModel.Core;
    using Windows.UI;
    using Windows.UI.ViewManagement;

    public class ViewHelper
    {
        public static void ExtensionTitleBar(Windows.UI.Xaml.Controls.Page current)
        {
            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
            var TitleBar = ApplicationView.GetForCurrentView().TitleBar;
            var setting = new UISettings();
            var ThemeBrush = setting.GetColorValue( UIColorType.Accent);
            Color RequestTheme = default( Color );
            switch ( current.RequestedTheme )
            {
                case Windows.UI.Xaml.ElementTheme.Dark:
                    RequestTheme = Colors.Black;
                    break;
                case Windows.UI.Xaml.ElementTheme.Light:
                    RequestTheme = Colors.White;
                    break;
                case Windows.UI.Xaml.ElementTheme.Default:
                    RequestTheme = Colors.Black;
                    break;
            }
            TitleBar.ButtonBackgroundColor = RequestTheme;
            TitleBar.ButtonForegroundColor = ThemeBrush;

            TitleBar.ButtonHoverBackgroundColor = ThemeBrush;
            TitleBar.ButtonHoverForegroundColor = RequestTheme;

            TitleBar.ButtonInactiveBackgroundColor = RequestTheme;
            TitleBar.ButtonInactiveForegroundColor = Colors.Gray;

            TitleBar.ButtonPressedBackgroundColor = ThemeBrush;
            TitleBar.ButtonPressedForegroundColor = RequestTheme;
        }
    }
}
